package com.lse_from.dto;

import com.baomidou.mybatisplus.annotation.TableField
import com.baomidou.mybatisplus.annotation.TableId
import com.fasterxml.jackson.annotation.JsonFormat
import com.fasterxml.jackson.databind.annotation.JsonSerialize
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer
import com.lse_from.config.pg_data_type.JSONBTypeHandlerPg
import com.lse_from.config.pg_data_type.JSONTypeHandlerPg
import com.lse_from.utils.PubVal
import java.time.LocalDateTime;
import java.io.Serializable;
import javax.validation.constraints.NotBlank

/**
 * <p>
 * 表单字段控制
 * </p>
 *
 * @author 祁雪
 * @since 2022-02-07
 */
class FromField : Serializable {

    /**
     * 主键
     */
    @TableId
    var id: String? = null

    /**
     * 表单id
     */
    @field:NotBlank(message = "请选择表单")
    var fromId: String? = null

    /**
     * 字段列表 包含组件的输入框组件等
     */
    @TableField(typeHandler = JSONBTypeHandlerPg::class)
    var field: String? = null

    /**
     * 表单属性
     */
    @TableField(typeHandler = JSONTypeHandlerPg::class)
    var formAttr: String? = null

    /**
     * 列样式
     */
    @TableField(typeHandler = JSONTypeHandlerPg::class)
    var colStyle: String? = null

    /**
     * 表格配置
     */
    @TableField(value = "table_attr", typeHandler = JSONTypeHandlerPg::class)
    var tsf: String? = null

    /**
     * 表单验证规则
     */
    @TableField(typeHandler = JSONTypeHandlerPg::class)
    var formRules: String? = null

    /**
     * 创建时间
     */
    @JsonSerialize(using = LocalDateTimeSerializer::class)
    @JsonFormat(pattern = PubVal.DATE_TIME_PATTERN)
    var createTime: LocalDateTime? = null

    /**
     * 更新时间
     */
    @JsonSerialize(using = LocalDateTimeSerializer::class)
    @JsonFormat(pattern = PubVal.DATE_TIME_PATTERN)
    var updateTime: LocalDateTime? = null


    override fun toString(): String {
        return "FromField{" +
                "id=" + id +
                ", fromId=" + fromId +
                ", colStyle=" + colStyle +
                ", formAttr=" + formAttr +
                ", field=" + field +
                ", tsf=" + tsf +
                ", formRules=" + formRules +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                "}"
    }
}
